﻿<UserControl x:Class="SocketChat.control.ColorSelect"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   >
    <Grid x:Name="LayoutRoot">
        <!--视觉状态定义区-->
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommStates">
                <VisualState x:Name="Enter">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="itemsTip" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Leave">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="itemsTip" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.1">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>


        <Canvas HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="cTip" Height="20" Width="20" Cursor="Hand" MouseLeave="GoToLeave" MouseEnter="GoToEnter">
            <Rectangle x:Name="rColor" Fill="Black" Width="20" Height="20" ToolTipService.ToolTip="选择发送的文字颜色"/>

            <!--tip显示区-->
            <ItemsControl x:Name="itemsTip" Canvas.Top="-21" Canvas.Left="0" Visibility="Collapsed">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Rectangle Fill="{Binding Color}" ToolTipService.ToolTip="{Binding Name}" Width="20" Height="20" Margin="0,0,1,0" MouseLeftButtonDown="ChangeColor"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Canvas>
    </Grid>
</UserControl>
